<?php

namespace app\yue\home;

use think\Db;

class Report extends Auth
{
    public function index()
    {
        $page  = input('page/d', 1);
        $items = Db::view('yue_round', 'id, create_time, avatarUrl, mode, nickName, status, win_side')
            ->view('yue_round_member', 'sort, side', 'yue_round.id = yue_round_member.rid')
            ->where(['yue_round_member.uid' => $this->uid, 'yue_round_member.status' => ['>', 0]])
            ->order('create_time desc')
            ->limit(15 * $page)
            ->select();

        foreach ($items as &$v) {
            $v['create_time'] = date('m/d H:i', $v['create_time']);
        }
        unset($v);

        $self        = model('yue_member')->find($this->uid);
        $rank_update = time() - $self->rank_update_time > $this->rank_change_interval;
        $rank_list   = '';
        if ($rank_update) {
            $rank_list = config('yue_rank');
            array_shift($rank_list);
        }

        return json([
            'err'         => 0,
            'items'       => $items,
            'rank'        => $self->rank,
            'rank_update' => $rank_update,
            'rank_list'   => $rank_list,
        ]);

    }

    public function chkRank()
    {

    }
}
